const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    orderId: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "订单编号",
      field: "order_id"
    },
    shopId: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "店铺编号",
      field: "shop_id"
    },
    orderSn: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "内部订单号",
      field: "order_sn",
      unique: "unique_order_sn"
    },
    outOrderSn: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "外部单号",
      field: "out_order_sn",
      unique: "unique_out_order_sn"
    },
    orderDate: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "订单日期",
      field: "order_date"
    },
    shopStatus: {
      type: DataTypes.INTEGER(2),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "订单状态",
      field: "shop_status"
    },
    buyerInfo: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "买家信息;JSON",
      field: "buyer_info"
    },
    receiverInfo: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "收货信息;JSON",
      field: "receiver_info"
    },
    payInfo: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "支付信息",
      field: "pay_info"
    },
    payAmount: {
      type: DataTypes.DECIMAL,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "应付金额;保留两位小数，单位元；使用积分时根据shop_item表的shop_price实时计算供参考",
      field: "pay_amount"
    },
    payPoint: {
      type: DataTypes.INTEGER(11),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "应付积分",
      field: "pay_point"
    },
    freight: {
      type: DataTypes.DECIMAL,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "运费",
      field: "freight"
    },
    buyerMessage: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "买家留言",
      field: "buyer_message"
    },
    remark: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "卖家备注",
      field: "remark"
    },
    logisticsSn: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "快递单号",
      field: "logistics_sn"
    },
    logisticsCompany: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "快递公司名称",
      field: "logistics_company"
    },
    sendDate: {
      type: DataTypes.DATE,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "发货日期",
      field: "send_date"
    },
    questionDesc: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "订单异常描述",
      field: "question_desc"
    }
  };
  const options = {
    tableName: "order",
    comment: "",
    indexes: []
  };
  const OrderModel = sequelize.define("orderModel", attributes, options);
  return OrderModel;
};